import { defineStore } from 'pinia'
let menu = localStorage.getItem('menu')
let menus:any = null
if (menu) {
    menus = JSON.parse(menu);
}
export const menuStore = defineStore({
  id: 'menu',
  state: () => {
    return {
        city: menus?.city||'',
        menu: menus?.menu||'',
        search_data: menus?.search_data||'',
        search_status: menus?.search_status||false,
        city_select_tag: menus?.city_select_tag||false,
        login_user: menus?.login_user||'',
        city_id: menus?.city_id||'',
        default_city: menus?.default_city||'',
        city_select_list: menus?.city_select_list||'',
        hot_city_select_list: menus?.hot_city_select_list||'',
    }
  },
  getters:{
      menushow() {
        this.menu = !this.menu
      },
  },
  actions: {
  },
   // 开启数据缓存
  persist: { //数据默认存在 sessionStorage 里，并且会以 store 的 id 作为 key
    enabled: true,
    strategies: [
      {
        key: 'menu',
        storage: localStorage,
      }
    ]
  }
})
